package view;


import com.trolltech.qt.gui.QMenu;
import com.trolltech.qt.gui.QMenuBar;
import com.trolltech.qt.gui.QWidget;

public class MenuBar extends QMenuBar {
	
	private final QMenu file ;
	private final QMenu editor ;
	
	
	public MenuBar(final QWidget parent) {
		super(parent);		
		file = new QMenu("File");
		editor = new QMenu("Editor");
		this.init();
	}
	
	
	private void init() {
		
		file.addAction("New Map");		
//		file.addAction("Open Map");		
//		file.addAction("Save Map");
		file.addAction("Exit");
		
		editor.addAction("Set Step Cars Number");
		editor.addAction("Add Cars");
		
		
		this.addMenu(file);
		this.addMenu(editor);
		editor.setEnabled(false);
		
		this.addAction("Play");
		this.addAction("Stop");
		
		this.actions().get(2).setEnabled(false);
		this.actions().get(3).setEnabled(false);
		
		
//		file.actions().get(2).setEnabled(false);

		
		
		// TODO tasto RESET
		file.actions().get(0).triggered.connect(((MainWindow)this.parent()).getMenuBarControl(), "fileNewMapTrigger()");
//		file.actions().get(1).triggered.connect(((MainWindow)this.parent()).getMenuBarControl(), "fileOpenMapTrigger()");
//		file.actions().get(2).triggered.connect(((MainWindow)this.parent()).getMenuBarControl(), "fileSaveMapTrigger()");
		file.actions().get(1).triggered.connect(((MainWindow)this.parent()).getMenuBarControl(), "fileExitTrigger()");
		
		editor.actions().get(0).triggered.connect(((MainWindow)this.parent()).getMenuBarControl(), "editorStepCarsTrigger()");
		editor.actions().get(1).triggered.connect(((MainWindow)this.parent()).getMenuBarControl(), "editorAddCarsTrigger()");
		
		this.actions().get(2).triggered.connect(((MainWindow)this.parent()).getMenuBarControl(), "editorPlayTrigger()");
		this.actions().get(3).triggered.connect(((MainWindow)this.parent()).getMenuBarControl(), "editorStopTrigger()");

		

	}
	
	public QMenu getFile(){
		return file;
	}
	
	public QMenu getEditor(){
		return editor;
	}
	
	public void setEnabledButtons(boolean b){
		this.actions().get(2).setEnabled(b);
//		this.actions().get(3).setEnabled(b);
	}
}
